import {wasm_grayscale} from 'zlyt-wasm';

export class ImageGray {
    static grayscale(u8Array: Uint8Array, extension: string, type: string): Promise<Blob> {
        const result = new Promise<Blob>((resolve, reject) => {
            try {
                const imageData = wasm_grayscale(u8Array, extension);
                const resultImg = new Blob([imageData.buffer], {type});
                resolve(resultImg);
            } catch (e) {
                reject(`grayscale error:${e}`);
            }
        });
        return result;
    }
}
